package cn.jietuo.factory;

/**
 * @author zhangx & jietuo_zx@163.com
 * @version 1.0
 * @date 2021/3/6
 * @description: 简单工厂模式
 */
public class SimpleFactory {

    public static Product createProduct(String type) {
        if (type.equals("A")) {
            return new ProductA();
        } else if (type.equals("B")) {
            return new ProductB();
        } else {
            return null;
        }
    }
}

interface Product {
}

class ProductA implements Product {
}

class ProductB implements Product {
}
